use strict;
use warnings;

#desc Test for doing Google Image search using number as a search term

use Test::More tests => 4;
use Test::NoWarnings;
use FindBin;
use File::Spec qw();
use lib File::Spec->catdir($FindBin::Bin, qw(.. lib));
use MichaelMilewski;

# should do something with the images :)
# TODO change to ascii art?
is(
    MichaelMilewski::isBeautifulNumber(1234567890),
    'http://farm1.static.flickr.com/27/37040513_3e3f6318b5.jpg'
);
is(
    MichaelMilewski::isBeautifulNumber('1234567890987654321'),
    'http://llnw0a.myvideo.de/movies/3d/thumbs/195930_1.jpg'
);
TODO: {
    local $TODO = 'support case for no results found', 1;
# for mock
# {"results":[{"GsearchResultClass":"GimageSearch","width":"240","height":"180","imageId":"czCGucPH0hjlVM","tbWidth":"110","tbHeight":"83","unescapedUrl":"http://llnw0a.myvideo.de/movies/3d/thumbs/195930_1.jpg","url":"http://llnw0a.myvideo.de/movies/3d/thumbs/195930_1.jpg","visibleUrl":"video.aol.com","title":"195930_1.jpg","titleNoFormatting":"195930_1.jpg","originalContextUrl":"http://video.aol.com/video-detail/1234567890987654321/3982718199","content":"\u003cb\u003e1234567890987654321\u003c/b\u003e","contentNoFormatting":"1234567890987654321","tbUrl":"http://images.google.com/images?q\u003dtbn:czCGucPH0hjlVM:llnw0a.myvideo.de/movies/3d/thumbs/195930_1.jpg"},{"GsearchResultClass":"GimageSearch","width":"320","height":"240","imageId":"s1iiEw624cH_PM","tbWidth":"118","tbHeight":"89","unescapedUrl":"http://www.freewebs.com/djworks/hippo.gif","url":"http://www.freewebs.com/djworks/hippo.gif","visibleUrl":"www.freewebs.com","title":"hippo.gif","titleNoFormatting":"hippo.gif","originalContextUrl":"http://www.freewebs.com/djworks/","content":"D J Works©","contentNoFormatting":"D J Works©","tbUrl":"http://images.google.com/images?q\u003dtbn:s1iiEw624cH_PM:www.freewebs.com/djworks/hippo.gif"},{"GsearchResultClass":"GimageSearch","width":"120","height":"90","imageId":"lOb22YO6s85TSM","tbWidth":"88","tbHeight":"66","unescapedUrl":"http://thumbnail.search.aolcdn.com/truveo/images/thumbnails/70/99/70991E8F0D6342.jpg","url":"http://thumbnail.search.aolcdn.com/truveo/images/thumbnails/70/99/70991E8F0D6342.jpg","visibleUrl":"video.aol.com","title":"70991E8F0D6342.jpg","titleNoFormatting":"70991E8F0D6342.jpg","originalContextUrl":"http://video.aol.com/video-detail/1234567890987654321/3982718199","content":"\u003cb\u003e1234567890987654321\u003c/b\u003e","contentNoFormatting":"1234567890987654321","tbUrl":"http://images.google.com/images?q\u003dtbn:lOb22YO6s85TSM:thumbnail.search.aolcdn.com/truveo/images/thumbnails/70/99/70991E8F0D6342.jpg"},{"GsearchResultClass":"GimageSearch","width":"120","height":"90","imageId":"4eEsygoHVYKTrM","tbWidth":"88","tbHeight":"66","unescapedUrl":"http://thumbnail.search.aolcdn.com/vsthumb8/tn/FC/70/FC7035E82810E09983B069.jpg","url":"http://thumbnail.search.aolcdn.com/vsthumb8/tn/FC/70/FC7035E82810E09983B069.jpg","visibleUrl":"video.aol.com","title":"FC7035E82810E09983B069.jpg","titleNoFormatting":"FC7035E82810E09983B069.jpg","originalContextUrl":"http://video.aol.com/video-detail/1234567890987654321/3982718199","content":"\u003cb\u003e1234567890987654321\u003c/b\u003e","contentNoFormatting":"1234567890987654321","tbUrl":"http://images.google.com/images?q\u003dtbn:4eEsygoHVYKTrM:thumbnail.search.aolcdn.com/vsthumb8/tn/FC/70/FC7035E82810E09983B069.jpg"},{"GsearchResultClass":"GimageSearch","width":"66","height":"44","imageId":"Hnb8g3i3n0wEDM","tbWidth":"65","tbHeight":"43","unescapedUrl":"http://www.child-neuro.org.uk/content/uploads/announcements/1234567890987654321s.jpg","url":"http://www.child-neuro.org.uk/content/uploads/announcements/1234567890987654321s.jpg","visibleUrl":"www.child-neuro.org.uk","title":"\u003cb\u003e1234567890987654321\u003c/b\u003es.jpg","titleNoFormatting":"1234567890987654321s.jpg","originalContextUrl":"http://www.child-neuro.org.uk/content/publish/announcements.shtml","content":"The International Symposium on \u003cb\u003e...\u003c/b\u003e","contentNoFormatting":"The International Symposium on ...","tbUrl":"http://images.google.com/images?q\u003dtbn:Hnb8g3i3n0wEDM:www.child-neuro.org.uk/content/uploads/announcements/1234567890987654321s.jpg"},{"GsearchResultClass":"GimageSearch","width":"240","height":"181","imageId":"cpU8DtBt1IFLdM","tbWidth":"110","tbHeight":"83","unescapedUrl":"http://i2.bebo.com/033b/13/mediuml/2007/05/25/19/3705720418a4484325339b345079960ml.jpg","url":"http://i2.bebo.com/033b/13/mediuml/2007/05/25/19/3705720418a4484325339b345079960ml.jpg","visibleUrl":"www.bebo.com","title":"3705720418a4484325339b345079960ml.jpg","titleNoFormatting":"3705720418a4484325339b345079960ml.jpg","originalContextUrl":"http://www.bebo.com/Profile.jsp?MemberId\u003d3705720418","content":"Ti \u003cb\u003e1234567890987654321\u003c/b\u003e \u0026lt;ti147\u0026gt;","contentNoFormatting":"Ti 1234567890987654321 \u0026lt;ti147\u0026gt;","tbUrl":"http://images.google.com/images?q\u003dtbn:cpU8DtBt1IFLdM:i2.bebo.com/033b/13/mediuml/2007/05/25/19/3705720418a4484325339b345079960ml.jpg"},{"GsearchResultClass":"GimageSearch","width":"90","height":"90","imageId":"1tp5eyTdwTBLTM","tbWidth":"78","tbHeight":"78","unescapedUrl":"http://i3.bebo.com/043a/9/medium/2008/05/22/21/1266941223a7811830524m.jpg","url":"http://i3.bebo.com/043a/9/medium/2008/05/22/21/1266941223a7811830524m.jpg","visibleUrl":"www.bebo.com","title":"1266941223a7811830524m.jpg","titleNoFormatting":"1266941223a7811830524m.jpg","originalContextUrl":"http://www.bebo.com/Profile.jsp?MemberId\u003d3705720418","content":"Ti \u003cb\u003e1234567890987654321\u003c/b\u003e \u0026lt;ti147\u0026gt;","contentNoFormatting":"Ti 1234567890987654321 \u0026lt;ti147\u0026gt;","tbUrl":"http://images.google.com/images?q\u003dtbn:1tp5eyTdwTBLTM:i3.bebo.com/043a/9/medium/2008/05/22/21/1266941223a7811830524m.jpg"},{"GsearchResultClass":"GimageSearch","width":"90","height":"90","imageId":"Bv2SEYgQKQM0_M","tbWidth":"78","tbHeight":"78","unescapedUrl":"http://i2.bebo.com/030b/3/medium/2007/03/03/00/3705720418a3753302768b319517634m.jpg","url":"http://i2.bebo.com/030b/3/medium/2007/03/03/00/3705720418a3753302768b319517634m.jpg","visibleUrl":"www.bebo.com","title":"3705720418a3753302768b319517634m.jpg","titleNoFormatting":"3705720418a3753302768b319517634m.jpg","originalContextUrl":"http://www.bebo.com/Profile.jsp?MemberId\u003d3705720418","content":"Ti \u003cb\u003e1234567890987654321\u003c/b\u003e \u0026lt;ti147\u0026gt;","contentNoFormatting":"Ti 1234567890987654321 \u0026lt;ti147\u0026gt;","tbUrl":"http://images.google.com/images?q\u003dtbn:Bv2SEYgQKQM0_M:i2.bebo.com/030b/3/medium/2007/03/03/00/3705720418a3753302768b319517634m.jpg"}],"cursor":{"pages":[{"start":"0","label":1},{"start":"8","label":2},{"start":"16","label":3},{"start":"24","label":4}],"estimatedResultCount":"213","currentPageIndex":0,"moreResultsUrl":"http://www.google.com/images?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003d1234567890987654321"}}
#    $VAR1 = {
#      'cursor' => {
#                    'moreResultsUrl' => 'http://www.google.com/images?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=1.23456789098765e+018'
#                  },
#      'results' => []
#    };
    is(
        MichaelMilewski::isBeautifulNumber(1234567890987654321),
        'http://www.google.com/images?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=1.23456789098765e+018'
    );
}
